<template>
  <div class="box">
    <div class="header">
      <span class="iconfont icon-fanhui" @click="back()"></span>
      <div class="title">登录</div>
    </div>
    <div class="center">
      <img src="../../static/登录.png" alt="" />
    </div>
    <div class="footer">
      <p>您好，小程序需要您的授权才能更好的为您服务哦~</p>
      <span>获取你的公开信息(昵称，头像，手机号等)</span>
      <div>
        <nagivator>
          <button class="button" @click="goBack()">取消</button>
        </nagivator>
        <button
          class="button"
          open-type="getUserInfo"
          userInfoo="getUserProfile"
          @click="goLogin()"
        >
          登录
        </button>
      </div>
    </div>
  </div>
</template>

<script>
import "../../static/iconfont/font_ed6w5zgn1gn/iconfont.css";
export default {
  methods: {
    back() {
      uni.navigateBack();
    },
    goLogin() {
      wx.getUserProfile({
        desc: "123",
        success(e) {
          // console.log(e, "eeee");
          // console.log(e.userInfo);
          wx.setStorage({
            key: "user",
            data: e.userInfo,
          });
          getApp().globalData.userInfo =e.userInfo;
          wx.switchTab({
            url: `/pages/my/index`,
          });
        },
      });
    },
    goBack() {
      wx.switchTab({
        url: "/pages/index/index",
      });
    },
  },
};
</script>

<style lang='scss'>
.box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  .header {
    width: 100%;
    height: 200rpx;
    background: linear-gradient(90deg, #0272f0, #36a2fe);
    display: flex;
    align-items: center;
    position: relative;
    span {
      position: absolute;
      left: 40rpx;
      top: 50%;
      transform: translate(0, -50%);
      color: #fff;
    }
    .title {
      width: 100%;
      text-align: center;
      color: #fff;
    }
  }
  .center {
    margin-top: 100rpx;
  }
  .footer {
    margin: 0 auto;
    width: 80%;
    border: 5rpx solid #eee;
    border-radius: 40rpx;
    box-shadow: 5rpx 5rpx #eee;
    margin-top: 100rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10rpx;
    p {
      margin-top: 10rpx;
      font-size: 35rpx;
      text-align: center;
    }
    span {
      margin-top: 10rpx;
      display: inline-block;
      font-size: 30rpx;
      color: #999999;
    }
    div {
      margin-top: 10rpx;
      display: flex;
      justify-content: space-around;
      align-items: center;
      .button {
        display: block;
        width: 220rpx;
        height: 80rpx;
        font-size: 35rpx;
        line-height: 80rpx;
        border-radius: 40rpx;
        margin-left: 30rpx;
      }
      .button:nth-child(1) {
        border: 1rpx solid #eee;
      }
      .button:nth-child(2) {
        color: #fff;
        background: linear-gradient(to bottom right, #f00, #f00);
      }
    }
  }
}
</style>